package edu.cicese.alz.swing;

import edu.cicese.alz.reports.ButtonPreview;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;

/**
 * Created by: Eduardo Quintana Contreras
 * Date: 28/06/12
 * Time: 12:42 PM
 */
public class LocationPreview extends ButtonPreview {

	private int size;
	private int[] widths = new int[]{4, 8, 12, 16, 20};

	public LocationPreview(Color color, Color borderColor, int size, int width, int height) {
		super(color, borderColor, width, height);
		this.size = size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	@Override
	public void paintComponent(Graphics g) {
		Graphics2D g2 = (Graphics2D) g;
		g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
	    g2.setStroke(new BasicStroke());
		g2.clearRect(0, 0, getWidth(), getHeight());
        int radius = widths[size];
        int diameter = radius * 2;
		int x = getWidth() / 2;
		int y = getHeight() / 2;
	    Area area = new Area(new Ellipse2D.Double(x - radius, y - radius, diameter, diameter));



        g2.setColor(color);
	    g2.fill(area);
        g2.setColor(borderColor);
		g2.setStroke(new BasicStroke(2));
	    g2.draw(area);
	}
}
